/*
--Archivo: test_sum_reg.c
--Fecha de creacion: 22/01/2011.
--Ultima fecha de modificacion: 04/02/2011.
--Diseñador: Miguel Peña.
--Diseño: Banco de pruebas del sumador encauzado.
--Proposito: Asignar estimulos a los puertos de entrada y simular su comportamiento.
*/

#include <stdio.h>
#include "genpat.h"

char* inttostr(int entier) {
  char* str;
  str = (char *) mbkalloc (32 * sizeof(char));
  sprintf(str,"%d",entier);
  return(str);
}
main() {
 
  DEF_GENPAT("test_sum_reg");

  DECLAR("CLK"        ,":2","B", IN   ,	      ""      , "");
  DECLAR("CONTROL_i"  ,":2","B", IN   ,	      ""      , "");
  DECLAR("A_i"        ,":2","B", IN   ,	"3 downto 0"  , "");
  DECLAR("B_i"        ,":2","B", IN   ,	"3 downto 0"  , "");
  DECLAR("S_o"        ,":2","B", OUT  ,	"3 downto 0"  , "");
  DECLAR("C_o"        ,":2","B", OUT  ,	      ""      , "");
  DECLAR("C_PREV_o"   ,":2","B", OUT  ,	      ""      , "");    
  DECLAR("vdd"        ,":2","B", IN   ,	      ""      , "");
  DECLAR("vss"        ,":2","B", IN   ,	      ""      , "");

  LABEL("test_sum_reg");
  
  SETTUNIT("ns");
  AFFECT("0" , "vdd"	, "1"); 
  AFFECT("0" , "vss"	, "0");

  AFFECT("0"    , "CLK"        ,      "0");
  AFFECT("0"    , "CONTROL_i"  ,      "0");
  AFFECT("0"    , "A_i"        , "0b0000");
  AFFECT("0"    , "B_i"        , "0b0000");

  AFFECT("+50"   , "CLK"       ,      "1");
  
  AFFECT("+50"  , "CLK"        ,      "0");
  AFFECT("+0"  , "A_i"         , "0b0011");//+3
  AFFECT("+0"  , "B_i"         , "0b1110");//-2

  AFFECT("+50"   , "CLK"        ,     "1");
  
  AFFECT("+50"  , "CLK"        ,      "0");
  AFFECT("+0"  , "A_i"         , "0b0110");//+6
  AFFECT("+0"  , "B_i"         , "0b0100");//+4

  AFFECT("+50"  , "CLK"        ,      "1");

  AFFECT("+50"  , "CLK"        ,      "0");
  AFFECT("+0"    , "CONTROL_i" ,      "1");
  AFFECT("+0"  , "A_i"         , "0b0011");//+3
  AFFECT("+0"  , "B_i"         , "0b1110");//-2
  
   
  AFFECT("+50"  , "CLK"        ,      "1");

  AFFECT("+50"  , "CLK"        ,      "0");
  AFFECT("+0"  , "CONTROL_i"   ,      "0");
  AFFECT("+0"  , "A_i"         , "0b1111");//-1
  AFFECT("+0"  , "B_i"         , "0b1111");//-1
  
  AFFECT("+50"  , "CLK"        ,      "1");


 int i = 0;
  for(i; i<10; i++) {
    AFFECT("+50"	, "CLK"		   , inttostr(i%2));
  }

  SAV_GENPAT();

  exit(0);
}

/* vim: tabstop=2 : expandtab : shiftwidth=2
*/
